<template>
  <div class="main_box">
    <CommonHeader title="异常反馈"></CommonHeader>
    <van-form class="main_form" @submit="onSubmit">
        <div class="head">{{ quotaInfo.quotaName }}</div>
        <div class="form_title">异常内容</div>
        <van-field
            v-model="form.content"
            required
            input-align="left"
            name="content"
            placeholder="请输入异常内容"
            maxlength="300"
            type="textarea"
            show-word-limit
            rows="6"
            :rules="[{ required: true, message: '' }]"
        >
        </van-field>
        <div class="btn_box">
            <van-button round type="info" native-type="submit">提 交</van-button>
        </div>
    </van-form>
  </div>
</template>

<script>
import CommonHeader from '@/components/commonHeader'
import { Toast } from 'vant'
export default {
  // eslint-disable-next-line
  name: 'AskHelp',
  components: {
    CommonHeader
  },
  data(){
    return{
        form:{
            content:''
        },
        quotaInfo:{}
    }
  },
  created(){
    const query = this.$route.query
    this.quotaInfo = query || []
  },
  methods: {
    onSubmit(){
        const params = {
          employeeId: sessionStorage.getItem('employId'),
          recordId: this.quotaInfo.id,
          issueYear: this.quotaInfo.issueYear,
          issueMonth: this.quotaInfo.issueMonth,
          content: this.form.content
      }
      this.$api.abnormalFeedback(params).then(res=>{
        if(res.errno === 200){
           Toast.success('提交成功');
            setTimeout(()=>{
              this.$router.go(-1)
            }, 1500)
        }else{
           Toast.fail(res.data);
        }
      })
    },
  },
}
</script>

<style scoped>
.main_box{
    min-height: 100vh;
    background-color: #f4f5fa;
}
.main_form{
    font-size:14px;
    color:#333;
    padding:15px;
}
.head{
  width: 100%;
  height: 44px;
  line-height: 44px;
  text-align: left;
  background-color: #fff;
  border-radius:5px;
  margin-bottom: 10px;  
  padding:0 16px;
  font-size:14px;
  color:#333;
  box-sizing: border-box;
}
.form_title{
    width: 100%;
    text-align: left;
    padding:10px 0;
}
.right_icon{
    display: inline-block;
    width: 8px;
    height: 15px;
    background: url("../../assets/image/select_icon.png") no-repeat;
    background-size: 100% 100%;
}
.btn_box >>> .van-button{
    width: 90%;
    margin-top: 20px;
}
.black >>> .van-field__control:disabled,.black >>> .van-field__control[disabled]{
    color:#333!important;
    opacity: 1;
    -webkit-text-fill-color: #000;
    -webkit-opacity: 1;
}
</style>